package com.zengfa.task.server.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zengfa.task.api.model.ReturnDTO;
import com.zengfa.task.server.application.JobAppService;
import com.zengfa.task.server.domain.entity.JobNode;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("job")
@Slf4j
public class JobController {

	@Autowired
	private JobAppService jobAppService;
	
	@GetMapping("/node-list")
    public ReturnDTO<List<JobNode>> getJobNodeList(@RequestParam("bizType") String bizType,@RequestParam("bizId") String bizId) throws Exception {
		List<JobNode> nodeList = jobAppService.getJobNodeList(bizType, bizId);
        return ReturnDTO.oK(nodeList);
    }
	
	@GetMapping("/stop")
    public ReturnDTO<Object> stopJob(@RequestParam("jobId") String jobId) throws Exception {
		log.info("停止任务:jobId:"+jobId);
		jobAppService.stopJob(jobId);
        return ReturnDTO.oK(null);
    }
	
}
